﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class DonViTinhDAO
    {
        public List<DonViTinhDTO> DanhSach()
        {
            string sql = "select * from DONVITINH";
            SqlConnection conn = DataProvider.ConnectionDB();
            SqlCommand command = new SqlCommand(sql, conn);
            SqlDataReader reader = command.ExecuteReader();

            List<DonViTinhDTO> danhsach = new List<DonViTinhDTO>();
            while (reader.Read())
            {
                DonViTinhDTO dto = new DonViTinhDTO();
                dto.MADVT = reader.GetString(0);
                dto.TENDVT = reader.GetString(1);
                danhsach.Add(dto);
            }
            conn.Close();
            return danhsach;
        }
    }
}
